﻿using System;
using System.Linq;
using System.Text;
using Crossroad.Utils.Extensions;
using SqlSugar;

namespace Crossroad.System.Admin.Model
{
    ///<summary>
    ///系统操作
    ///</summary>
    [Serializable]
    [SugarTable("admin_option")]
    public partial class Option
    {
        public Option()
        {
            LoadDefVal();
        }

        public Option(bool loadDef)
        {
            if (loadDef)
                LoadDefVal();
        }

        private void LoadDefVal()
        {
            this.sort = Convert.ToInt32("99");
            this.updateTime = Convert.ToInt32("0");
            this.updatorId = Convert.ToInt32("0");
            this.createTime = Convert.ToInt32("0");
            this.creatorId = Convert.ToInt32("0");
        }

        /// <summary>
        /// Desc:图标
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string icon { get; set; }

        /// <summary>
        /// Desc:id
        /// Default:
        /// Nullable:False
        /// </summary>           
        [SugarColumn(IsPrimaryKey = true)]
        public string id { get; set; }

        /// <summary>
        /// Desc:操作名称
        /// Default:
        /// Nullable:False
        /// </summary>           
        public string name { get; set; }

        /// <summary>
        /// Desc:排序
        /// Default:99
        /// Nullable:False
        /// </summary>           
        public int sort { get; set; }

        /// <summary>
        /// Desc:修改时间
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "update_time")]
        public int? updateTime { get; set; }

        /// <summary>
        /// Desc:修改人
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "updator_id")]
        public int? updatorId { get; set; }

        /// <summary>
        /// Desc:创建时间
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "create_time")]
        public int? createTime { get; set; }

        /// <summary>
        /// Desc:创建人
        /// Default:0
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "creator_id")]
        public int? creatorId { get; set; }


        #region 扩展字段

        private string _createTimeText;
        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string createTimeText
        {
            set { _createTimeText = value; }
            get
            {
                if (_createTimeText.IsNullOrEmpty())
                    return _createTimeText = (createTime??0).ToDateTimeStr();

                return _createTimeText;
            }
        }

        /// <summary>
        /// 创建人
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string creatorName { set; get; }

        private string _updateTimeText;
        /// <summary>
        /// 修改时间
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string updateTimeText
        {
            set { _updateTimeText = value; }
            get
            {
                if (_updateTimeText.IsNullOrEmpty())
                    return _updateTimeText = (updateTime??0).ToDateTimeStr();

                return _updateTimeText;
            }
        }

        /// <summary>
        /// 修改人
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string updatorName { set; get; }

        /// <summary>
        /// 图标地址
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string iconText { set; get; }

        /// <summary>
        /// 值
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string value { set; get; }

        /// <summary>
        /// 是否选中
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public bool selected { set; get; } = false;

        #endregion


    }
}
